import pickle
import numpy as np
import os

for file in ['X.pkl', 'y.pkl']:
    if os.path.exists(file):
        size = os.path.getsize(file)
        print(f"{file} 大小: {size} 字节")
        if size > 0:
            try:
                with open(file, 'rb') as f:
                    data = pickle.load(f)
                print(f"{file} 类型: {type(data)}")
                if isinstance(data, (list, np.ndarray)):
                    print(f"{file} 长度: {len(data)}")
                    if len(data) > 0:
                        print(f"{file} 第一个元素类型: {type(data[0])}")
                        if isinstance(data[0], np.ndarray):
                            print(f"{file} 第一个元素形状: {data[0].shape}")
                arr = np.array(data)
                print(f"{file} 转换为 numpy 后形状: {arr.shape}, dtype: {arr.dtype}")
            except Exception as e:
                print(f"{file} 读取错误: {e}")
        else:
            print(f"{file} 文件为空!")
    else:
        print(f"{file} 不存在")
    print()